﻿using Furion.DynamicApiController;
using IndoorPosition.Server.Core.Utils;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IndoorPosition.Server.Application
{
    /// <summary>
    /// 蓝牙基站相关服务接口
    /// </summary>
    public class StationAppService: IDynamicApiController
    {
        IStationService _stationService;

        public StationAppService(IStationService stationService)
        {
            _stationService = stationService;
        }

        /// <summary>
        /// 添加基站
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<int> Add(StationInputDto input)
        {
            return await _stationService.AddAsync(input);
        }

        /// <summary>
        /// 删除基站
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task Delete(int id)
        {
            await _stationService.DeleteAsync(id);
        }

        /// <summary>
        /// 更新基站信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task Update(StationInputDto input)
        {
            await _stationService.UpdateAsync(input);
        }

        /// <summary>
        /// 获取某一个基站信息
        /// </summary>
        /// <param name="uuid"></param>
        /// <returns></returns>
        public async Task<StationDto> Get(string uuid)
        {
            return await _stationService.GetAsync(uuid);
        }

        /// <summary>
        /// 分页获取基站
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<PagedList<StationDto>> List(PageInputDto input)
        {
            return await _stationService.ListAsync(input);
        }

        /// <summary>
        /// 获取所有基站
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<List<StationDto>> ListAll(SearchInputDto input)
        {
            return await _stationService.ListAllAsync(input);
        }

        /// <summary>
        /// 获取某一楼层的所有基站
        /// </summary>
        /// <param name="floorId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<StationDto>> ListByFloor(int floorId)
        {
            return await _stationService.ListByFloorAsync(floorId);
        }

        /// <summary>
        /// 设置基站位置
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task SetPositionAsync(PositionInputDto input)
        {
            await _stationService.SetPositionAsync(input);
        }
    }
}
